﻿<%@ WebHandler Language="C#" Class="JsonHandler" %>

using System;
using System.Web;

public class Result
{
    public int percent { get; set; }
}

public class JsonHandler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "application/json";
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        
        System.Type type = typeof( Result );
        System.Runtime.Serialization.Json.DataContractJsonSerializer serializer
            = new System.Runtime.Serialization.Json.DataContractJsonSerializer(type);

        Result result = new Result();
        result.percent = 80;

        serializer.WriteObject(context.Response.OutputStream, result);
        
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}